//
//  EvaluationDetailsCell.m
//  phmall
//
//  Created by admin on 2017/12/18.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "EvaluationDetailsCell.h"

@implementation EvaluationDetailsCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+ (instancetype)theShareCellWithTableView:(UITableView *)tableView{
    
    static NSString *ID = @"SetCell";
    EvaluationDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[EvaluationDetailsCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle=UITableViewCellSelectionStyleNone;;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.goodsImage=[[UIImageView alloc]init];
        self.goodsImage.image=[UIImage imageNamed:@"头像"];
        ViewBorderRadius(self.goodsImage, 3, 0.5, [UIColor groupTableViewBackgroundColor]);
        [self.contentView addSubview:self.goodsImage];
        
        self.name=[[UILabel alloc]init];
        self.name.text=@"Clinique 保湿纯原浆水果...";
        self.name.font=[UIFont systemFontOfSize:15];
        [self.contentView addSubview:self.name];
        
        self.time=[[UILabel alloc]init];
        self.time.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.time.font=[UIFont systemFontOfSize:13];
        [self.contentView addSubview:self.time];
        
        self.evaluate=[UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:self.evaluate];
        [self.evaluate setTitle:@"好评" forState:UIControlStateNormal];
        [self.evaluate setImage:[UIImage imageNamed:@"前往"] forState:UIControlStateNormal];
        [self.evaluate setTitleColor:[UIColor colorWithHexString:@"adadad"] forState:UIControlStateNormal];
        self.evaluate.titleLabel.font=[UIFont systemFontOfSize:13];
       
        self.line=[UIView new];
        self.line.backgroundColor=[UIColor groupTableViewBackgroundColor];
        [self.contentView  addSubview:self.line];
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.contentView.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    
    [self.goodsImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(10);
        make.centerY.offset(0);
        make.width.equalTo(self.goodsImage.mas_height);
        make.top.offset(10);
        make.bottom.offset(-10);
    }];
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodsImage.mas_right).offset(10);
        make.top.offset(10);
    }];
    
    [self.time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.goodsImage.mas_right).offset(10);
        make.bottom.offset(-10);
    }];
    [self.evaluate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-10);
        make.centerY.offset(0);
    }];
    [self.evaluate layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleRight imageTitleSpace:5];
    
    [self.line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.offset(0);
        make.left.right.offset(0);
        make.height.mas_equalTo(1);
    }];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
-(void)setModel:(EvaluationLisModel *)model{
    _model=model;
    self.name.text=model.from_id;
    if (model.level==0) {
        [self.evaluate setTitle:Localized(@"中评") forState:UIControlStateNormal];
    }
    if (model.level==1) {
        [self.evaluate setTitle:Localized(@"好评") forState:UIControlStateNormal];
    }
    if (model.level==-1) {
        [self.evaluate setTitle:Localized(@"差评") forState:UIControlStateNormal];
    }
    self.time.text=[PublicClass timeWithTimeIntervalString:model.reg_date];
    [self.goodsImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@union/%@",IMGURL,model.img[0][@"member_image"]]] placeholderImage:[UIImage imageNamed:@"图片空白页"]];
}
@end
